package com.welink.cmp.statemachine.machine;

import com.welink.base.statemachine.Action;
import com.welink.base.statemachine.StateMachine;
import com.welink.base.statemachine.builder.StateMachineBuilder;
import com.welink.base.statemachine.builder.StateMachineBuilderFactory;
import com.welink.cmp.statemachine.StateMachineIdContent;
import com.welink.cmp.statemachine.context.VpcCtx;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author yanwei li create  2024-06-02 22:58
 */
@Component
@Slf4j
public class VpcMachine {


    @PostConstruct
    public void init(){
        final StateMachineBuilder<VpcState, VpcEvent, VpcCtx> builder = StateMachineBuilderFactory.create();

        builder.addTransition()
                .from(VpcState.NEW)
                .to(VpcState.ACTIVE)
                .on(VpcEvent.ALLOCATED)
                .perform(doAction());

        builder.addTransition()
                .from(VpcState.ACTIVE)
                .to(VpcState.RETIRED)
                .on(VpcEvent.RELEASE)
                .perform(doAction());

        final StateMachine<VpcState, VpcEvent, VpcCtx> build = builder.build(StateMachineIdContent.single_state_machine_id);

    }
    private Action<VpcState, VpcEvent, VpcCtx> doAction() {
        return (from, to, event, ctx)->{



        };
    }


}